<?php
header("content-type:text/html;charset=utf-8");
include "../config/mysql.php";
session_start();
if(isset($_SESSION['username'])){
                
                  $title=$_POST["title"];
                  $author=$_POST["author"];
                  $content=$_POST["content"];
                  $time=$_POST["date"];
                  $addtime=strtotime($time);
                  $kid=$_POST["modules"]; //获取这个分类的代号;               
                  // $tr=$pdo->query("select pid from article_content where kid=$kid order by pid desc");
                  // $str=$tr->fetch(PDO::FETCH_ASSOC);
                  // $pid=$str["pid"]+1;
                 
                
                  // $str=$tr->lastInsertId();
              
                  $content = htmlspecialchars($content,ENT_QUOTES);
                 // echo $content;
                  // var_dump("update article_content set content=$content where id=$id");exit;
   // $tr=$pdo->exec("update article_content set content='$content' where id=$id");
   // $tr2=$pdo->exec("update article_content set title='$title',author='$author',kid=$kid where id=$id");
     $tr=$pdo->exec("insert into article_content (title,content,author,addtime,kid) values('$title','$content','$author',$addtime,$kid)");
     
                 if($tr){
                 	header("refresh:1;url=../index.php");
                 	print("添加成功,请稍后..<br>");
                 }
                 else{
                 	header("refresh:10;url=../addarticle.php?id=$id");
                 	print("添加失败,请稍后..<br>");
                 }

}else{
  header("Location:../log.php");
      exit();
}

?>